package web;

import VO.BuyListVO;
import entity.Commodity;
import service.BuyService;
import service.CommodityService;
import service.impl.BuyServiceImpl;
import service.impl.CommodityServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author zy
 * @create 2021/12/5 13:21
 */
@WebServlet("/CommodityListByType")
public class CommodityListByType extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        response.setCharacterEncoding("utf-8");
        CommodityService commodityService = new CommodityServiceImpl();
        String type = request.getParameter("type");
        List<Commodity> commoditiesByType = commodityService.getCommoditiesByType(type);

        request.setAttribute("commoditiesByType",commoditiesByType);
        request.getRequestDispatcher("/buyList.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
